package com.xbang.attendance.web.action.system.department;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.demo2do.lighturl.annotation.Action;
import com.xbang.attendance.entity.department.Department;
import com.xbang.attendance.entity.system.EntityWarning;
import com.xbang.attendance.service.SystemService;
import com.xbang.core.page.Result;
import com.xbang.core.struts.support.SearchActionSupport;

public class departmentIndex extends SearchActionSupport {

	@Autowired
	private SystemService systemService;
	private Department dinfo;

	public Department getDinfo() {
		return dinfo;
	}

	public void setDinfo(Department dinfo) {
		this.dinfo = dinfo;
	}

	private List<Department> departmentinfo = new ArrayList<Department>();

	@Override
	public void resetCustomerSearchCriteria() {
		// TODO Auto-generated method stub

	}

	@Action("/system/department/list")
	public String list() throws Exception {

		String hqlSentence = "FROM Department department WHERE 1 = 1";

		Result result = systemService.searchByPage(hqlSentence,
				searchComponent, page);

		departmentinfo = result.getItems();
		page = result.getPage();
//		departmentinfo.get(0).getDepartmentName();
//		departmentinfo.get(0).getGrade();
		return "index";
	}
/*
	@Action("/system/department/add")
	public String add() throws Exception{
		System.out.print("in");
		return "detail";
		//return "detail";
	}*/
	
	@Action("/system/department/save")
	public String save() throws Exception {
		if (null != dinfo) {
			systemService.save(dinfo);
		}
    return "";
	//	return "r:/system/department/list";
	}

	public void setSystemService(SystemService systemService) {
		this.systemService = systemService;
	}

	public List<Department> getDepartmentinfo() {
		return departmentinfo;
	}

	public void setDepartmentinfo(List<Department> departmentinfo) {
		this.departmentinfo = departmentinfo;
	}

}
